package com.jacobson.huobi.api

import com.alibaba.fastjson.JSONObject
import com.jacobson.huobi.common.HttpAuthentication
import com.jacobson.huobi.entities.ForgetInfo
import com.jacobson.huobi.entities.LoginUserInfo
import com.jacobson.huobi.entities.RegisterInfo
import com.jacobson.huobi.entities.response.CommonResponse
import com.jacobson.huobi.entities.response.LoginPageResponse
import io.reactivex.Observable
import retrofit2.http.Body
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path


interface LoginAndRegisterApi {

    /**
     * 获取手机验证码
     */
    @POST("captcha/send/{telephone}")
    fun getVertiCode(
        @Path("telephone") telephone: String
    ): Observable<LoginPageResponse>


    /**
     * 注册用户
     */
    @Headers("Content-Type: application/json", "Accept: */*")
    @POST("auth/register")
    fun registerUser(
        @Body registerInfo: RegisterInfo
    ): Observable<LoginPageResponse>


    /**
     * 登陆用户
     */
    @Headers("Content-Type: application/json", "Accept: */*")
    @POST("auth/login")
    fun login(
        @Body loginUserInfo: LoginUserInfo
    ): Observable<CommonResponse<JSONObject>>

    /**
     * 获取登陆验证码
     */
    @POST("captcha/kaptcha")
    fun getKaptcha(
    ): Observable<CommonResponse<JSONObject>>

    /**
     * 获取版本信息
     */
    @POST("app_upgrade/newest")
    fun getVersionUpdate(
    ): Observable<CommonResponse<JSONObject>>

    /**
     * 登出
     */
    @POST("logout")
    @Headers(HttpAuthentication.HEADER)
    fun logout(
    ): Observable<CommonResponse<JSONObject>>

    /**
     * 刷新token
     */
    @POST("auth/refresh_token")
    @Headers(HttpAuthentication.REFRESH_TOKEN,HttpAuthentication.HEADER,HttpAuthentication.TOKEN)
    fun refreshToken(
    ): Observable<CommonResponse<JSONObject>>



    /**
     * 忘记密码
     */
    @Headers("Content-Type: application/json", "Accept: */*")
    @POST("auth/modify_password")
    fun forget(@Body forgetInfo: ForgetInfo): Observable<CommonResponse<JSONObject>>
}